<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('服务商分润调整项列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>服务商编号：</label>
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                <label>服务商名称：</label>
                                <input type="text" name="agentName"/>
                            </li>
                            <li>
                                <label>调整事项：</label>
                                <select name="adjustType" th:with="type=${@dict.getType('adjust_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>调整金额：</label>
                                <input type="text" name="adjustMoney"/>
                            </li>
                            <li>
                                <label>备注：</label>
                                <input type="text" name="note"/>
                            </li>
                            <li>
                                <label>添加人：</label>
                                <input type="text" name="addMan"/>
                            </li>
                            <li class="select-time">
                                <label>添加时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginAddTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endAddTime]"/>
                            </li>
                            <li>
                                <label>审核状态：</label>
                                <select name="examineState" th:with="type=${@dict.getType('examine_status')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>审核人：</label>
                                <input type="text" name="examineMan"/>
                            </li>
                            <li class="select-time">
                                <label>审核时间：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginExamineTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endExamineTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="upload()" shiro:hasPermission="agentInfo:distributionAdjust:upload">
                    <i class="fa fa-plus"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="agentInfo:distributionAdjust:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-primary single disabled" onclick="examine(1)" shiro:hasPermission="agentInfo:distributionAdjust:examine">
                    <i class="fa fa-edit"></i> 审核通过
                </a>
                <a class="btn btn-danger single disabled" onclick="examine(2)" shiro:hasPermission="agentInfo:distributionAdjust:examine">
                    <i class="fa fa-remove"></i> 审核拒绝
                </a>

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('agentInfo:distributionAdjust:edit')}]];
        var adjustTypeDatas = [[${@dict.getType('adjust_type')}]];
        var examineStateDatas = [[${@dict.getType('examine_status')}]];
        var prefix = ctx + "agentInfo/distributionAdjust";

        $(function() {
            var options = {
                url: prefix + "/list",
                updateUrl: prefix + "/edit/{id}",
                exportUrl: prefix + "/export",
                clickToSelect: true,
                modalName: "服务商分润调整项",
                columns: [{
                    radio: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'agentNum',
                    title: '服务商编号'
                },
                {
                    field: 'agentName',
                    title: '服务商全称'
                },
                {
                    field: 'adjustType',
                    title: '调整事项',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(adjustTypeDatas, value);
                    }
                },
                {
                    field: 'adjustMoney',
                    title: '调整金额'
                },
                {
                    field: 'note',
                    title: '备注'
                },
                {
                    field: 'addMan',
                    title: '添加人'
                },
                {
                    field: 'addTime',
                    title: '添加时间'
                },
                {
                    field: 'examineState',
                    title: '审核状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(examineStateDatas, value);
                    }
                },
                {
                    field: 'examineMan',
                    title: '审核人'
                },
                {
                    field: 'examineTime',
                    title: '审核时间'
                }]
            };
            $.table.init(options);
        });


        function upload(){
            $.modal.open("导入数据", prefix+"/upload","800","250");
        }

        function examine(type) {
            var rows = $.table.selectFirstColumns();
            if (rows.length == 0) {
                $.modal.alertWarning("请选择一条记录");
                return;
            }
            var confirmStr = "通过";
            if (type == 2){
                confirmStr = "拒绝";
            }
            $.modal.confirm("确认要审核"+confirmStr+"选中的数据吗?", function() {
                var data = { "id": rows.join(), "examineState": type};
                $.operate.submit(prefix+"/examine", "post", "json", data);
            });
        }
    </script>
</body>
</html>